#ifndef _3761_USERDATA_H_
#define _3761_USERDATA_H_
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include <string>
#include "3761.h"
using namespace std;


class UserData
{
public:
	smtPack m_data;
    sMtData m_sData[1020];//这里做为备用空间给unpack用，不然会写穿到UserBuffer.m_data里面，打印出乱码
public:
	UserData(void);
	//~UserData(void);
public:
	UserData& init(void);

	//address
	UserData& setRegion(const string& region="4301");
	UserData& setTerminal(uint16_t terminal=256);
	UserData& setTeam(bool isTeam = false);
	UserData& setMac(uint8_t mac=0);

	//control
	UserData& setAfn(eMtAFN afn = AFN_00_CONF);
	UserData& setDir(eMtDir dir = MT_DIR_S2M);
	UserData& setPrm(eMtPRM prm = MT_PRM_PASIVE);
	UserData& setAcd(bool acd=false);

	//sequence
	UserData& setTpv(bool haveTP=false);
	UserData& setPos(eMtPos pos = MT_POS_SIGLE);
	UserData& setCon(bool con=true);
	UserData& setSeq(uint8_t seq);

	//AUX
	UserData& setHavePW(bool havePW=false);
	UserData& setHaveEC(bool haveEC=false);
	UserData& setPw(const uint8_t pw[]);
	UserData& setEc(uint8_t ec1, uint8_t ec2);
	UserData& setTp(uint8_t pfc, uint8_t delay, struct tm& t);

	//userdata
	UserData& setNum(uint16_t n = 1);
	UserData& setCmd(eMtCmd cmd, int index = 0);
	UserData& setPn(uint16_t pn, int index = 0);
	UserData& setApp(bool haveApp, int index = 0);

public:
	string getRegionString(void)const;
	int getRegion(void)const;
	int getTerminal(void)const;
	int getTeam(void)const;
	int getMac(void)const;

	//control
	int getAfn(void)const;
	int getDir(void)const;
	int getPrm(void)const;
	int getAcd(void)const;

	//sequence
	int getTpv(void)const;
	int getPos(void)const;
	int getCon(void)const;
	int getSeq(void)const;

	//AUX
	int getHavePW(void)const;
	int getHaveEC(void)const;
	const uint8_t* getPw(void)const;
	int getEc(void)const;
	int getTp(void)const;

	//userdata
	int getNum(void)const;
	int getCmd(int index=0)const;
	int getFn(int index=0)const;
	int getPn(int index=0)const;
	int getApp(int index=0)const;
	uMtApp& getApp(int index=0);
public:
	virtual bool packup(void){return false;}
	virtual bool unpack(void){return false;}
};


#endif//_3761_USERDATA_H_
